home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 4412 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  2.1 KB

  1. Path: mail2news.demon.co.uk!genesis.demon.co.uk
  2. From: Lawrence Kirby <fred@genesis.demon.co.uk>
  3. Newsgroups: comp.lang.c
  4. Subject: Re: quick decision: is n a power of 2?
  5. Date: Sun, 04 Feb 96 13:13:04 GMT
  6. Organization: none
  7. Message-ID: <823439584snz@genesis.demon.co.uk>
  8. References: <Pine.OSF.3.91.960119114608.18779E-100000@io.UWinnipeg.ca> <TANMOY.96Jan21104404@qcd.lanl.gov> <4e6rs0$dvl@ns.RezoNet.NET> <9601251245.AA12220@dxmint.cern.ch> <822791542snz@genesis.demon.co.uk> <4er59u$1tc@nntp5.u.washington.edu>
  9. Reply-To: fred@genesis.demon.co.uk
  10. X-NNTP-Posting-Host: genesis.demon.co.uk
  11. X-Newsreader: Demon Internet Simple News v1.27
  12. X-Mail2News-Path: genesis.demon.co.uk
  13.  
  14. In article <4er59u$1tc@nntp5.u.washington.edu>
  15.            gah@u.washington.edu "G. Herrmannsfeldt" writes:
  16.  
  17. >Are there any ones-complement machines (I think CDC used to make them),
  18. >with C compilers that generate the two's complement for -u on an unsigned int?
  19.  
  20. The bit manipulations required to perform unsigned arithmetic are different
  21. for those required to perform 1's complement arithmetic. The compiler would
  22. have to generate instructions to perform the correct bit manipulations for
  23. -u and these would have to be a different sequence to those generated for -s
  24. (on a signed int), unless the compiler simulates a 2's complement environment
  25. for the C program.
  26.  
  27. The nice thing about 2's complement is that in most cases the bit
  28. manipulations required are the same as for unsigned arithmetic. The
  29. difference is how the result is interpreted (for example how condition
  30. codes are tested).
  31.  
  32. >I suppose it makes a little sense, but are there really any?
  33. >
  34. >And, for that matter, what about BCD machines?  Maybe they are rare, too.
  35.  
  36. That is a different case because C doesn't support BCD as a representation
  37. model. The compiler for such a system wuould therefore have to jump through
  38. significant hoops to simulate a 'pure' binary environment for the C
  39. program to run in.
  40.  
  41. -- 
  42. -----------------------------------------
  43. Lawrence Kirby | fred@genesis.demon.co.uk
  44. Wilts, England | 70734.126@compuserve.com
  45. -----------------------------------------
  46.